<?php

include('Mail.php');
include('globals.php');
require('logger.php');

$mailtype = $_GET['mailtype'];

if ($_GET['power'])
	$power = "Yes";
else
	$power = "No";

$status = "This message is your official confirmation that you, the dealer, now have a table for the 2014 event.  "
			. "All your details have been provided and if you paid via credit card, we have already proccessed "
			. "your payment.  If you paid via check, an address has been provided to you for mailing that to us.  "
			. "Please note:  The post office box in Illinois is no longer in service!  Please do not send "
			. "your check to that address, as it will not be received!  "
			. "Thank you for applying, and we'll see you at the show!";

$recipients = "dealers@anthrocon.org, " . $_GET['email'];
//$recipients = $_GET['email'];
$headers['From'] = "Anthrocon Dealer's Room Staff <dealers@anthrocon.org>";
$headers['Subject'] = "Anthrocon Dealers Room: Assignment Notification";
$params["username"] = /* REDACTED */;
$params["password"] = /* REDACTED */;
$params["host"] = "ssl://smtp.googlemail.com";
$params["port"] = 465;
$params["auth"] = TRUE;

$body = "Hello from the Anthrocon Dealer's Staff!

" . $status . "

Dealership: " . htmlspecialchars_decode($_GET['dealership']) . "
Lead Dealer: " . $_GET['dealername'] . "
Payment Method: " . $payment_methods[$_GET['paymentmethod']] . "
Table Size: " . $table_types[$_GET['tablesize']] . "
Table Assignment: " . $_GET['assignment'] . "
Power: " . $power  . "

A chart of all our dealers will be up on the site before the event, so you can reference where you are, and who's sharing space with you.

As always, if you've got any questions, you can get right back to us at dealers@anthrocon.org, or just by responding to this message.";

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);

$send = $mail_object->send($recipients, $headers, $body);

//this needs to be modified to die-on-fail--otherwise it continues onwards and marks the mail sent
//even on things like 502s and 503s.
//2014 Me: is that true?  I wrote that years ago, and it's never appeared to be an issue.
if (PEAR::isError($send)) {
	echo("<p>" . $send->getMessage() . "</p>");
	} else {
	echo("<p>Message successfully sent!</p>");
}

RecordLogEntry($_GET['dealership']);

$mark_notified_query = "UPDATE " . $dealers_table . " SET is_notified = '1', notification_date = \"" . date("d/m/Y") .	"\" WHERE dealership_name = \"" . addslashes(htmlspecialchars_decode($_GET['dealership'])) . "\"";

if (!($link = mysql_connect($host, $user, $password)))
	die('Could not connect: ' . mysql_error());

if (!(mysql_select_db($database)))
	die('Could not select db ' . $database . ': ' . mysql_error());

if (!(mysql_query($mark_notified_query, $link)))
	die('Could not execute query "' . $mark_notified_query . '": ' . mysql_error());

?>